<?php
/**
 * User: Lijun
 * Date: 2017/7/4.
 * Time: 14:04.
 * Comment:
 */
namespace Home\Widget;
use Think\Controller;

class PublicWidget extends Controller{
    public function top(){
        $where["pid"] = 0;
        $where["id"] = array("neq",48);
        $about_us = M("category") -> where($where) -> select();
        foreach($about_us as $k => $v){
            $about_us[$k]['child'] = M("category") -> where(array("pid" => $v["id"])) -> select();
        }
        $time = time();
    	$week = getTimeWeek($time);
        $this -> assign("aboutus",$about_us);
        $this -> assign("column",$column);
        $this -> assign('week',$week);
    	$this -> assign('time',$time);
        $this -> display("Public:top");
    }

    public function footer(){
        $this -> display("Public:footer");
    }

    public function server(){
        $url = $_SERVER['PHP_SELF'];
        $categorys = substr(strstr($url,'php/'),4); //URL不带入口名称
        $category = strstr($categorys,'/',true);    //控制器名称
        $cate = I("get.cname");
        $where["pname"] = $category;
    	$AboutUs = M("category") -> where($where) -> select();
        foreach($AboutUs as $k => $v){
            $AboutUs[$k]["brother"] = M("category") -> where(array("pid" => $v["id"])) -> select();
        }
        $server = M("category") -> where(array("pid" => 6)) -> order("id desc") ->limit(6) -> select();
        $cates = I("get.pname");
        $this -> assign("cate",$cate);
        $this -> assign("cates",$cates);
    	$this -> assign('AboutUs',$AboutUs);
        $this -> assign("server",$server);
        $this -> display("Public:server");
    }
}
